﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class KofaxInvoice
    {
        public int id = 0;
        //Header
        public string BatchClassId = "";
        public string BatchClassName = "";
        public string BatchStatus = "";
        public string DocumentId = "";
        public string DocumentClassName = "";
        public string VendorCode = "";
        public string VendorName = "";
        public string InvoiceNo = "";
        public DateTime InvoiceDate = new DateTime(2000, 1, 1);
        public string PoNumber = "";
        public decimal SubTotal = 0;
        public decimal Tax = 0;
        public decimal TotalAmount = 0;
        //detail
        public string PartNo = "";
        public string Description = "";
        public decimal Qty = 0;
        public decimal UnitPrice = 0;
        public decimal TotalPrice = 0;
       //FIlename
        public string FileName = "";
        public DateTime CreatedDate = new DateTime(2000, 1, 1);
        public DateTime ModifiedDate = new DateTime(2000, 1, 1);
        public string pickup_flag = "";
        public string batch_id = "";

         public IList LineItems = new ArrayList();
         public KofaxInvoice() { }
         public KofaxInvoice(SqlDataReader rd)
         {
             id = rd["id"] is DBNull ? id : Convert.ToInt32(rd["id"]);

             BatchClassId = rd["BatchClassId"] is DBNull ? BatchClassId : rd["BatchClassId"].ToString();
             BatchClassName = rd["BatchClassName"] is DBNull ? BatchClassName : rd["BatchClassName"].ToString();
             BatchStatus = rd["BatchStatus"] is DBNull ? BatchStatus : rd["BatchStatus"].ToString();
             DocumentId = rd["DocumentId"] is DBNull ? DocumentId : rd["DocumentId"].ToString();
             DocumentClassName = rd["DocumentClassName"] is DBNull ? DocumentClassName : rd["DocumentClassName"].ToString();
             VendorCode = rd["VendorCode"] is DBNull ? VendorCode : rd["VendorCode"].ToString();
             VendorName = rd["VendorName"] is DBNull ? VendorName : rd["VendorName"].ToString();
             InvoiceNo = rd["InvoiceNo"] is DBNull ? InvoiceNo : rd["InvoiceNo"].ToString();
             InvoiceDate = rd["InvoiceDate"] is DBNull ? InvoiceDate : Convert.ToDateTime(rd["InvoiceDate"]);
             PoNumber = rd["PoNumber"] is DBNull ? PoNumber : rd["PoNumber"].ToString();
             SubTotal = rd["SubTotal"] is DBNull ? SubTotal : Convert.ToDecimal(rd["SubTotal"]);
             Tax = rd["Tax"] is DBNull ? Tax : Convert.ToDecimal(rd["Tax"]);
             TotalAmount = rd["TotalAmount"] is DBNull ? TotalAmount : Convert.ToDecimal(rd["TotalAmount"]);
             PartNo = rd["PartNo"] is DBNull ? PartNo : rd["PartNo"].ToString();
             Description = rd["Description"] is DBNull ? Description : rd["Description"].ToString();
             Qty = rd["Qty"] is DBNull ? Qty : Convert.ToDecimal(rd["Qty"]);
             UnitPrice = rd["UnitPrice"] is DBNull ? UnitPrice : Convert.ToDecimal(rd["UnitPrice"]);
             TotalPrice = rd["TotalPrice"] is DBNull ? TotalPrice : Convert.ToDecimal(rd["TotalPrice"]);

             CreatedDate = rd["CreatedDate"] is DBNull ? CreatedDate : Convert.ToDateTime(rd["CreatedDate"]);
             ModifiedDate = rd["ModifiedDate"] is DBNull ? ModifiedDate : Convert.ToDateTime(rd["ModifiedDate"]);
             pickup_flag = rd["pickup_flag"] is DBNull ? pickup_flag : rd["pickup_flag"].ToString();
             batch_id = rd["batch_id"] is DBNull ? batch_id : rd["batch_id"].ToString();
         }
         public void AddItem(KofaxInvoice item)
         {
             item.BatchClassId = BatchClassId;
             item.BatchClassName = BatchClassName;
             item.BatchStatus = BatchStatus;
             //item.Description = Description;
             item.DocumentClassName = DocumentClassName;
             item.DocumentId = DocumentId;
             item.InvoiceDate = InvoiceDate;
             item.InvoiceNo = InvoiceNo;
             //item.PartNo = PartNo;
             item.PoNumber = PoNumber;
             //item.Qty = Qty;
             item.SubTotal = SubTotal;
             item.Tax = Tax;
             item.TotalAmount = TotalAmount;
             //item.TotalPrice = TotalPrice;
             //item.UnitPrice = UnitPrice;
             item.VendorCode = VendorCode;
             item.VendorName = VendorName;
             item.FileName = FileName;
             LineItems.Add(item);
         }

    }
}
